import ChatCacheDB from "@/static/js/indexdb/chat"
const indexdbparams = {
  dbName: "myChatCache",       // 数据库名称
  cacheTableName: "message_cache",  // 对象存储(表)名称
  keyPath: "messages_id",             // 主键字段名
  indexs: [                  // 索引数组
    { name: "room_id", unique: false },
  ]
}
const my_chat_cache = new ChatCacheDB(indexdbparams)
const handlePing = (data, ws) => { 
    console.log('收到ping')
    // console.log(data)
    ws.sendMessage('ping', data)
}

const send_message_callback = (data, ws) => {
    if (data['status']) { 
        my_chat_cache.putData(data)
        const DATA = {
            'room_id': data['room_id'],
            'user_id': data['sender_id'],
            'message_id': data['message_id'],
        }
    }
   
}


export {
    send_message_callback,
    handlePing,
}